/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vehicle.beans;

import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import vehicle.bol.CarBOL;
import vehicle.entity.Abums;
import vehicle.entity.Vehicles;

/**
 *
 * @author lab1
 */
@ManagedBean
@SessionScoped
public class CarBean {

    /** Creates a new instance of CartBean */
    private List<Vehicles> listvehicle;
    private String valueSearch = "";

    public String getValueSearch() {
        return valueSearch;
    }

    public void setValueSearch(String valueSearch) {
        this.valueSearch = valueSearch;
    }
    CarBOL bolcart = new CarBOL();

    public List<Vehicles> getListvehicle() {
        if (checksearch == false || valueSearch == "") {
            listvehicle = bolcart.showAllVehicle();
        } else {
            listvehicle = bolcart.searchCarByVehicleName(valueSearch);
        }
        return listvehicle;
    }

    public CarBean() {
    }

    public String showDetailCar(Vehicles veshow) {
        return null;
    }
    boolean checksearch = false;

    public String searchCar() {
        checksearch = true;
        return null;
    }
    private Vehicles vehi;
    private List<Abums> listAbum;

    public List<Abums> getListAbum() {
        return listAbum;
    }

    public Vehicles getVehi() {
        return vehi;
    }
    private List<Vehicles> listProductLienQuan;

    public List<Vehicles> getListProductLienQuan() {
        return listProductLienQuan;
    }

    public String showDetailVehicle(Vehicles ve1) {
        listProductLienQuan=new ArrayList<Vehicles>();
        for (Vehicles veh : listvehicle) {
            if (veh.getBrandID() == ve1.getBrandID()) {
                listProductLienQuan.add(veh);
            }
        }
        vehi = ve1;
        listAbum = bolcart.showAbumByVehicleID(ve1.getVehicleID());
        return "showdetail";
    }
    public String dathang()
    {
        return "dathang";
    }
}
